<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>操作内联样式</title>
    <style>
        #box1 {
            width: 200px;
            height: 200px;
            background-color: red;
        }
    </style>
    <script type='text/javascript'>
        window.onload = function () {
            var box1 = document.getElementById('box1');
            var btn01 = document.getElementById('btn01');
            var btn02 = document.getElementById('btn02');
            btn01.onclick = function () {
                //alert('hello');
                //修改box1的大小

                box1.style.backgroundColor = 'blue';
            };
            btn02.onclick = function (){
                //alert(box1.currentStyle.width);
                var obj = getComputedStyle(box1,null)

            };
        };
    </script>
</head>

<body>
<button id="btn01">点我一下</button>
<button id="btn02">点我读取</button>
<br><br>
<div id="box1"></div>
</body>

</html>